package com.gitee.T6;

import java.util.Scanner;

public class t6 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //输入数组并排序
        int[] g = new int[0];
        System.out.println("输入数组g（输入0结束）：");
        while (true) {
            int num = sc.nextInt();
            if (num == 0) {
                break;
            }
            g = creatArr(g, num);
        }
        sortArr(g);
        int[] s = new int[0];
        System.out.println("输入数组s（输入0结束）：");
        while (true) {
            int num = sc.nextInt();
            if (num == 0) {
                break;
            }
            s = creatArr(s, num);
        }
        sortArr(s);
        //计数
        int count = 0;
        for (int i = 0; i < g.length; i++) {
            for (int j = 0; j < s.length; j++) {
                if (g[i] <= s[j]) {
                    s[j] = 0;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
    //创建数组
    public static int[] creatArr(int[] arr, int num) {
        int[] newArr = new int[arr.length + 1];
        for (int i = 0; i < arr.length; i++) {
            newArr[i] = arr[i];
        }
        newArr[arr.length] = num;
        return newArr;
    }
    //冒泡排序
    public static void sortArr(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
}
